#include <fstream>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
  
  int time; // Bessie 跑步的时间
  int lDistance = 0; // left distance
  int rDistance = 0;
  
  int K = 0;
  int X = 0; // 冲过终点的速度要求

  for (int currentSpeed = 1; ; ++currentSpeed) {
    lDistance += currentSpeed;
    ++time;

    if (lDistance + rDistance >= K) {
      // 在没有超速的情况已经到终点
      return time;
    }

    if (currentSpeed >= X) {
      // 以 currentSpeed == X 的这一刹那开始
      rDistance += currentSpeed;
      ++time;

      if (lDistance + rDistance >= K) {
        // 只能维持住当前 currentSpeed 到结束
        return time;
      }
    }
  }

  return 0;
}
